<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<%@ include file="../../common/jsp/sheetHeader.jsp" %>
<script>
	$(document).ready(function() {
		createSheet();
	});
	
	function createSheet() {
		createIBSheet2(document.getElementById("viewArea"),"mySheet","100%","400px");
		
		setConfig();
		setInitHeaders();
	}
	
	function setConfig() {
		var cfg = {FrozenCol:0, SearchMode:smLazyLoad, Page:30};
		mySheet.SetConfig(cfg);
	}
	
	function setInitHeaders() {
		var headers = [
		   			{Text:"모델번호|평형|단가(A)|판매가(B)\nA * 1.03 / 100|현금구입가(C)\n A * 0.9 / 100|할부구입가(D)\nA * 0.93 / 100|현금부담액\nB-C|할부부담액\nB-D", Align:"Center"}
		   		];
		var info = {Sort:1,ColMove:1,ColResize:1,HeaderCheck:0};
		
		mySheet.InitHeaders(headers, info);
	}
	
	function setInitColumns() {
		var cols = [
					{Type:"Text",Width:130},
					{Type:"Text",Width:100,ColMerge:0},
					{Type:"Int",Width:80,SaveName:"A", Align:"Right",ColMerge:0},
					{Type:"AutoSum",Width:85,SaveName:"B",Format:"#,##0.00",CalcLogic:"|A|*1.03/100", Align:"Right",ColMerge:0},
					{Type:"AutoSum",Width:85,SaveName:"C",Format:"#,##0.00",CalcLogic:"|A|*0.9/100", Align:"Right",ColMerge:0},
					{Type:"AutoSum",Width:85,SaveName:"D",Format:"#,##0.00",CalcLogic:"|A|*0.93/100", Align:"Right",ColMerge:0},
					{Type:"AutoAvg",Width:85,Format:"#,##0.00",CalcLogic:"|B|-|C|", ColMerge:1, Align:"Right",ColMerge:0},
					{Type:"AutoAvg",Width:85,Format:"#,##0.00",CalcLogic:"|B|-|D|", Align:"Right",ColMerge:0}
				];
		
		mySheet.InitColumns(cols);
		
		mySheet.FitColWidth();
		
		doAction('search');
	}
	
	/*Sheet 각종 처리*/
	function doAction(sAction) {
		
		switch(sAction) {
			case "search":		//조회
				mySheet.DoSearch("../data/sheet_data2.xml");
				break;
		    break;
		}
	}
</script>
<title>Column간의 연산 예제</title>
</head>
<body>
<div id="main">
	<%@ include file="../../common/jsp/sheetNavi.jsp" %>
	<div id="title">Column간의 연산 예제</div>
	<div id="desc">
		CalcLogic은 해당 데이터에 대한 계산 공식을 설정한다.<br>
		컬럼 데이터의 값이 공식에 사용 되는 경우 "|"로 감싸서 공식에 설정한다. 기본적으로 ""으로 설정된다.<br>
		예를 들어, 5컬럼 값에 2를 곱해서 3컬럼 값을 더해야 한다면 공식은 "|5| * 2 + |3|"와 같이 설정된다.<br>
		공식이 설정 된 경우 다른 컬럼의 값이 바뀌었거나 조회했을 때 자동으로 계산 처리한다.<br>
		컬럼번호가 아니라 다른 컬럼의 SaveName 을 사용하여 공식을 작성할 수도 있다.<br>
		예를 들어 위 공식에서 5컬럼의 SaveName이 "pay"였다고 하면 공식은 "|pay|*2+|3|"이라고 설정해도 같은 효과를 볼 수 있다.<br>
		<br>
		var cols = [<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Type:"Text",Width:130},<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Type:"Text",Width:100,ColMerge:0},<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Type:"Int",Width:80,SaveName:"A", Align:"Right",ColMerge:0},<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Type:"AutoSum",Width:85,SaveName:"B",Format:"#,##0.00",<font color="#FF0000"><u>CalcLogic:"|A|*1.03/100"</u></font>, Align:"Right",ColMerge:0},<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Type:"AutoSum",Width:85,SaveName:"C",Format:"#,##0.00",<font color="#FF0000"><u>CalcLogic:"|A|*0.9/100"</u></font>, Align:"Right",ColMerge:0},<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Type:"AutoSum",Width:85,SaveName:"D",Format:"#,##0.00",<font color="#FF0000"><u>CalcLogic:"|A|*0.93/100"</u></font>, Align:"Right",ColMerge:0},<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Type:"AutoAvg",Width:85,Format:"#,##0.00",<font color="#FF0000"><u>CalcLogic:"|B|-|C|"</u></font>, ColMerge:1, Align:"Right",ColMerge:0},<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{Type:"AutoAvg",Width:85,Format:"#,##0.00",<font color="#FF0000"><u>CalcLogic:"|B|-|D|"</u></font>, Align:"Right",ColMerge:0}<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;];
	</div>

	<div id="functionArea">
		<span>
			<input type="button" value="조회하기" onclick="setInitColumns()">
		</span>
	</div>
	
	<div id="viewArea">
	</div>
</div>
</body>
</html>